home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / SYNAPSE / BKSYNAPS.C next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  2.0 KB  |  56 lines

  1. // Dynamic link library implementation of NeuroSolutions BackSynapse component 
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /*************************************************************/
  6. /* Macros to access the PE layers and weights in matrix form */
  7.  
  8. #define in(i,j)        errorIn[j+i*inCols]
  9. #define out(i,j)    errorOut[j+i*inCols]
  10.  
  11. /********************************/
  12. /* Backpropagation of component */
  13.  
  14. __declspec(dllexport) void performBackSynapse(
  15.     DLLData *instance,    // Pointer to instance data (may be NULL)
  16.     DLLData *dualInstance,    // Pointer to the forward synapses instance data (may be NULL)
  17.     NSFloat    *errorIn,     // Pointer to the input error layer of processing elements (PEs)
  18.     int     inRows,        // Number of rows of PEs in the input layer (don't forget that input and output are reversed)
  19.     int     inCols,        // Number of columns of PEs in the input layer
  20.     NSFloat    *errorOut,     // Pointer to the output error layer 
  21.     int     outRows,    // Number of rows of PEs in the output layer
  22.     int     outCols,    // Number of columns of PEs in the output layer
  23.     NSFloat    *input         // Pointer to the output layer of the forward synapse
  24.     )
  25. {
  26.     int    i,
  27.         inCount=inRows*inCols,
  28.         outCount=outRows*outCols,
  29.         count=inCount<outCount? inCount: outCount;
  30.  
  31.     for (i=0; i<count; i++)
  32.         errorOut[i] += errorIn[i];
  33. }
  34.  
  35. /******************************************/
  36. /* Management of instance data (OPTIONAL) */
  37. /*
  38. __declspec(dllexport) DLLData *allocBackSynapse(
  39.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  40.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  41.     int     inRows,            // Number of rows of PEs in the input layer
  42.     int     inCols,            // Number of columns of PEs in the input layer
  43.     int     outRows,        // Number of rows of PEs in the output layer
  44.     int     outCols            // Number of columns of PEs in the output layer
  45.     )
  46. {
  47.     DLLData *instance = allocDLLInstance(oldInstance);
  48.     return instance;
  49. }
  50.  
  51. __declspec(dllexport) void freeBackSynapse(DLLData *instance)
  52. {
  53.     freeDLLInstance(instance);
  54. }
  55. */
  56.